	subroutine exner
	include 'cst.inc'
c****************************************************************************
c   determines the depth changes across the grid using the exner
c   equation.  latteral and offshore boundaries are set to constant
c   fluxes and hence do not erode or deposit. the shoreline cells are
c   given special treatment as explained below.
c****************************************************************************
c
c --- Compute the depth changes over the surf zone ---
c
	do i=2,imax-1
	   deltah = -(qlit(i)-qlit(i-1))*deltay*dt/(deltax*deltay)
	   deltah = deltah*(1./(1.-pore))
	   h(i,jshore(i)) = h(i,jshore(i))+deltah
	   !This if condition is for river inflow
	   if(i.eq.iriv) then
	     h(i,jshore(i)) = h(i,jshore(i)) + qriv*dt/(deltax*deltay)
	   endif
c	write(88,*)i,deltah,qlit(i-1)-qlit(i)
      enddo 

	iim=imax-1
	do i=2,iim
	   jjm=jshore(i)   !was originally jshore(i)-1
	   do j=2,jjm
	      dqxdx=(qxrt(i-1,j)-qxrt(i,j))*deltay*dt
	      dqydy=(qyup(i,j-1)-qyup(i,j))*deltax*dt
	      deltah= (1./(1.-pore))*(dqxdx + dqydy)/(deltax*deltay)
	      h(i,j)=h(i,j) + deltah
	   enddo   
   	enddo
c
	do j=1,jshore(1)
	   h(1,j)=h(2,j)
      enddo
	do j=1,jshore(imax)
	   h(imax,j)=h(imax-1,j)
      enddo

c
c   there is no sediment flux gradient through the boundaries so the
c	following holds:
c
c   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
c   commented out on 11-20-00
c
c	 jlmt=jshore(1)
c	do 40 j=2,jlmt
c	 dqydy=(qyup(1,j-1)-qyup(1,j))*deltax*dt
c	 deltah=(1./(1-pore))*(dqydy/(deltax*deltay))
c	 h(1,j)=h(1,j)+deltah
c  40 continue
c
c	 jlmt=jshore(imax)
c	do 45 j=2,jlmt
c	 dqydy=(qyup(imax,j-1)-qyup(imax,j))*deltax*dt
c	 deltah=(1./(1.-pore))*(dqydy/(deltax*deltay))
c	 h(imax,j)=h(imax,j)+deltah
c  45	continue
c
c	do 50 i=2,imax
c	dqxdx=(qxrt(i-1,1)-qxrt(i,1))*deltay*dt
c	deltah=(1./(1.-pore))*(dqxdx/(deltax*deltay))
c	h(i,1)=h(i,1)+deltah
c  50	continue 
c
c   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
c   take care of the boundaries by leaving the depth unchanged
c
c
c   take care of the boundaries by leaving the depths unchanged
c
c
c   deal with 'shelf/surf corner'cell balances. these are the places
c   where surf zone cell abuts a shoreface cell in the x-direction.
c   they correspond to actual places where such convergences occur
c   but in this model the effect is concentrated in individual cell
c   boundaries.
c
c   search for "left" or "right" corner cells. then adjust
c
cw	do 100 i=2,iim
cw	  if(jshore(i).eq.jshore(i-1))goto 100
cw	   if (jshore(i).gt.jshore(i-1)) goto 90
cw	   j=jshore(i)
cw	  h(i,j)=  h(i,j) + (qxrt(i-1,j)*deltay*dt)
c	  write(*,*)'should not be here:lt',i,j
c	  stop
cw	goto 100
cw   90	   ii=i-1
cw	   jj=jshore(i)
cw	  h(i,j)=  h(i,j) - (qxrt(ii,j)*deltay*dt)
c	  write(*,*)'should not be here:gt',i,j
c	  stop
c  100	 continue 
c
c
	 return
	 end			   